#include "heap.h"
#include<stdio.h>

void HeapSort(int* a, int n)
{
	HP hp;
	HeapInit(&hp);

	for (int i = 0; i < n; ++i)
	{
		HeapPush(&hp, a[i]);
	}
	int i = 0;
	while (!HeapEmpty(&hp))
	{
		int top = HeapTop(&hp);
		a[i++] = top;
		HeapPop(&hp);
	}
	HeapDestroy(&hp);
}

int main()
{
	int a[] = { 7,8,3,5,1,9,5,4 };
	HeapSort(a, sizeof(a) / sizeof(int));
	return 0;
}